define(function (require, exports, module) {


    require("andrew/login-card/index.js");

    var toastr = require("third/toastr/index.js");

    var VueComponent = new Vue({
        el: '#app',
        data: {
            form: {
                loginName: 'admin',
                pwd: '123456',
                checkCode: '',
                quickLogin: false
            }
        },
        mounted: function () {
            var quickLogin = localStorage.getItem("quickLogin") == "true" ? true : false;

            if (quickLogin) {
                this.form.quickLogin = quickLogin;
                var pz_ticket = localStorage.getItem("pz_ticket") || "";
                if (quickLogin == true && pz_ticket != "") {

                    // toastr.success("快捷起动中..");
                    // setTimeout(function () {
                    //     window.location.href = "02_home.html";
                    // }, 1000);

                }
            }
        },
        methods: {
            submit: function () {


                if (this.form.loginName == "") {
                    toastr.error("用户名不能为空!");
                    return false;
                }

                var re = new RegExp(/^[a-zA-Z0-9_-]{4,16}$/);
                if (!re.test(this.form.loginName)) {
                    toastr.error("用户名要求长度4~16位,字母，数字，下划线，减号!");
                    return false;
                }

                if (this.form.pwd == "") {
                    toastr.error("密码不能为空!");
                    return false;
                }

                var re = new RegExp(/^[A-Za-z0-9]{6,16}$/);
                if (!re.test(this.form.pwd)) {
                    toastr.error("密码要求6-16字母数字组成");
                    return false;
                }

                if (this.form.checkCode == "") {
                    toastr.error("验证码不能为空!");
                    return false;
                }

                var re = new RegExp(/^[A-Za-z0-9]{4,6}$/); // 暂时用4位的
                if (!re.test(this.form.checkCode)) {
                    toastr.error("密码要求长度4~16位,字母，数字，下划线，减号!");
                    return false;
                }



                // 一般post post提交吧,后面代码回调里

                localStorage.setItem("pz_ticket", "ABCDEF123");

                //登陆成功后 看密码是否需要记录
                if (this.form.quickLogin) {
                    localStorage.setItem("quickLogin", true);
                } else {
                    localStorage.removeItem("quickLogin");
                }

                window.location.href = "home.html"; // 所有页面ticket都从  pz_ticket 取

            },
            resetGo: function () {
                this.form.loginName = '';
                this.form.pwd = '';
                this.form.checkCode = '';
            }
        }
    });

});